package com.msb.test13;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Test01 {
    public static void main(String[] args) {
        String currentDir = System.getProperty("user.dir");
        System.out.println(System.getProperty("java.home"));
        System.out.println("当前工作目录: " + currentDir);
        //文件对象
        File file = new File(currentDir+"/TestFirstModule/src/com/msb/test13/test.txt");
        Path fullPath = Paths.get(currentDir, "/TestFirstModule/src/com/msb/test13/test.txt");
        System.out.println("fullPath");
        System.out.println(fullPath);
        File file1 = new File(currentDir+"/TestFirstModule/src/com/msb/test13/test1.txt");
        //"管子"-流-输入字符流
        try {
            FileReader fr = new FileReader(file);
            int contents = fr.read();
            while (contents != -1) {
                System.out.print((char) contents);
                contents = fr.read();
            }
            fr.close();
        }catch (Exception e){
            e.printStackTrace();
        }

        try{
            FileWriter fr = new FileWriter(file1);
            fr.write("12345678910");
            fr.close();
        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
